import {type FormSchema} from '#/../../../packages/@core/ui-kit/form-ui/src/types'
import {type VxeGridPropTypes} from '#/adapter/vxe-table'
import {getDictOptions, getOptionsFromDict} from "#/utils";
import {AppGrade} from "#/views/toc/data";
import {ref} from "vue";
import {FileUpload} from "#/components/upload";


export const table_columns:VxeGridPropTypes.Columns=[
  {field:'icon',title:'图标',},
  {field:'background',title:'背景图片',},
  {field:'podcastName',title:'播客名称',},
  {field:'url',title:'播放地址'},
  {field:'categoryId',title:'播客类型',},
  {field:'grade',title:'推荐年级',},
  {field:'subject',title:'学科',},
  {field:'remark',title:'介绍',},
  {title:'操作',slots:{default:'option'}},
]

export const p_options=ref<any[]>([])
export const form_schema:FormSchema<any>[]=[
  {
    fieldName:'icon',
    component:'ImageUpload',
    label:'图标',
  },
  {
    fieldName:'background',
    component:'ImageUpload',
    label:'背景图片'
  },
  {
    fieldName:'podcastName',
    component:'Input',
    label:'播客名称',
    rules:'required'
  },
  {
    fieldName:'url',
    component:FileUpload,
    label:'播客地址',
    componentProps:{
      maxNumber:1
    },
    rules:'required'
  },
  {
    fieldName:'categoryId',
    component:'Select',
    label:'播客类型',
    rules:'required',
    componentProps:{
      remote:true,
      filterable:true,
      options:p_options,
      multiple:false,
    }
  },
  {
    fieldName:'grade',
    component:'Select',
    componentProps:{
      options:getOptionsFromDict(AppGrade),
      multiple:false
    },
    label:'推荐年级',
    rules:'required'
  },
  {
    fieldName:'subject',
    component:'Select',
    componentProps:{
      options: getDictOptions('subject_name','string')
    },
    label:'推荐学科',
    rules:'required'
  },
  {
    fieldName:'remark',
    component:'Input',
    label:'介绍'
  },
]
